﻿@model Himall.Web.Areas.Admin.Models.Market.BonusModel

@{
    Layout = null;
}
<html>
<head>
    <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>领取成功</title>
    <link href="~/Content/bootstrap.min.css" rel="stylesheet" />
    <link href="~/Areas/Mobile/Templates/Default/Content/custom.css" rel="stylesheet" />
    <script src="~/Scripts/jquery-1.7.1.min.js"></script>

</head>

<body>
</body>
</html>

<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
<script type="text/javascript">
    wx.config({
        debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
        appId: '@ViewBag.AppId', // 必填，公众号的唯一标识
        timestamp: @ViewBag.Timestamp , // 必填，生成签名的时间戳
        nonceStr: '@ViewBag.NonceStr', // 必填，生成签名的随机串
        signature: '@ViewBag.Signature',// 必填，签名，见附录1
        jsApiList: [ 'onMenuShareTimeline' , 'onMenuShareAppMessage'] // 必填，需要使用的JS接口列表，所有JS接口列表见附录2
    });

    wx.ready(function () {
        // 判断当前版本是否支持指定 JS 接口，支持批量判断
        wx.checkJsApi({
            jsApiList: [ 'onMenuShareTimeline' , 'onMenuShareAppMessage' ],
            success: function (res)
            {
                LoadBody();
                $('.bonus-f-hd').height($('.bonus-f-hd').width()*15/32)
                $('#subCate').click(function() {
                    $('.share-guide').fadeIn()
                });
                if(res.checkResult.onMenuShareTimeline)   //朋友圈
                {

                }
                if(res.checkResult.onMenuShareAppMessage)  //朋友
                {

                }
            }
        });

        wx.onMenuShareAppMessage({
            title: '@Model.Name',
            desc: '@Model.Remark',
            link: '@Model.ReceiveHref',
            imgUrl: '@Model.ImagePath',
            type: 'link',
            dataUrl: '',
            success: function (res) {
                setshare();
            },
            cancel: function (res) {
            }
        });

        wx.onMenuShareTimeline({
            title: '@Model.Name',
            link: '@Model.ReceiveHref',
            imgUrl: '@Model.ImagePath',
            success: function () {
                setshare();
            },
            cancel: function () {

            }
        });

    });

    function LoadBody()
    {
        var html = "";
        html += '<div class="container">';
        html += ' <div class="bonus-finish">';
        html +='<div class="bonus-f-hd"><img src="@Model.ImagePath" /></div>';
        html +='<p class="name">@(Model.MerchantsName)的礼包</p>';
        html +='<p class="words">@Model.Blessing</p>';
        html +='<h3><span>@ViewBag.Price</span> 元</h3>';
        html +='<p><button type="button" id="subCate">我还想要红包</button></p>';
        html +='<p><button type="button" id="register" class="btn-invite">邀请好友注册，各得积分奖励</button></p>';
        html +='<p class="primary">提示：现金已进入到您个人资产中心，可在资产管理处进行查看及提现</p>';
        html += '</div>';
        html += '<div class="share-guide"></div>';
        html += '</div>';

        $("body").html(html);

        $("#register").click(function(){
            location.href = "/m-weixin/UserInvite";
        })
        $(".share-guide").click(function(){
            $(this).hide();
        })
    }

    function setshare()
    {
        var id = @Model.Id;
        var openId = '@ViewBag.OpenId';
        $.post("/m-weixin/Bonus/SetShare",{ id : id , openId : openId },function( result ){
            location.href = "/m-weixin/bonus/index/"+id;
        })
    }

</script>

